import Stack from "./01_创建栈结构(数组)";

function decimeToBinary(dec: number): string {
  const stack = new Stack<number>();

  while (dec > 0) {
    const result = dec % 2;
    stack.push(result);

    dec = Math.floor(dec / 2);
  }

  let binary = "";
  while (!stack.isEmpty()) {
    binary += stack.pop();
  }

  return binary;
}

console.log(decimeToBinary(35)); // 1010
